const TIM = require('./utils/tim-wx.js');
import TIMUploadPlugin from './utils/tim-upload-plugin.js';

App({
  onLaunch() {
    let that = this;
    let options = { SDKAppID: 1400566413 };
    let tim = TIM.create(options); //初始化，生成tim实例
    tim.setLogLevel(1); //设置日志级别 0-4；0普通、1 release级别，SDK 输出关键信息，生产环境时建议使用，2告警、3错误、4无
    tim.registerPlugin({ 'tim-upload-plugin': TIMUploadPlugin }); // 在 login 前调用，以支持文件上传腾讯云对象存储
    //监听 tim not ready
    let onSdkNotReady = function (event) {
      console.log('tim not ready:', event);
      that.globalData.tim_ready = false;
    };
    tim.on(TIM.EVENT.SDK_NOT_READY, onSdkNotReady);
    that.$tim = tim;
  },

  $tim: {}, //全局tim实例

  globalData: {
    tim_ready: false,
    user_list: [{ userID: 'user01' }, { userID: 'user02' }, { userID: 'user03' }],
    login_user: '',
    tim_login_info: {},
  }
})
